<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div id="div1">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <p style="color: #0070C0;text-align: center;font-size: large;font-weight: bold;">未通过合同申请一览表</p><br>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-table layui-form" id="test" lay-filter="test"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="div2">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <!--<table class="layui-table layui-form" id="test"></table>-->
                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0
                               width="100%" bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY>
                            <TR>
                                <TD>
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                        <TBODY>
                                        <TR bgColor=#ffffff>
                                            <TD align=middle width="100%" bgColor=#ffffff colSpan=20
                                                height=22>
                                                <H2 style="color: #0070c0"><B>合同申请明细</B></H2>
                                            </TD>
                                        </TR>
                                        <TR class=t1>
                                            <TD width="20%">询价书名称：</TD>
                                            <TD class=t2 width="30%">
                                                <A href="javascript:alert('对应询价书详细')" id="enquireName3"></A>
                                            </TD>
                                            <TD width="20%">报价份数：</TD>
                                            <TD class=t2 width="30%" id="statQuote"></TD>
                                        </TR>
                                        <TR class=t1>
                                            <TD width="20%">最高报价（元）：</TD>
                                            <TD class=t2 width="30%" id="topQuote"></TD>
                                            <TD width="20%">最低报价（元）：</TD>
                                            <TD class=t2 width="30%" id="lowQuote"></TD>
                                        </TR>
                                        </TBODY>
                                    </TABLE>
                                </TD>
                            </TR>
                            </TBODY>
                        </TABLE>

                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0
                               width="100%" bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY>
                            <TR>
                                <table id="tableContract" class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>

                                </table>
                                <TD>
                                    <table  class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                        <tbody >
                                        <tr class=t1>
                                            <td align=middle><B>需求计划数量</B></td>
                                            <td align=middle id="orderNum"></td>
                                            <td align=middle><B>订货计划数量</B></td>
                                            <td align=middle id="dingHuoNum"></td>
                                        </tr>
                                        <tr class=t1>
                                            <td align=middle>总金额（元）</td>
                                            <td align=middle colspan="3" id="sumPrice"></td>
                                        </tr>
                                        <tr>
                                            <td align=middle>部长审核结果</td>
                                            <td style="text-align: center" id="leadAgree">
                                            </td>
                                            <td align=middle>部长审核意见</td>
                                            <td id="leadOpinion">
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </TD>
                            </TR>
                            </TBODY>
                        </TABLE>

                        <BR>
                        <div style="text-align: center">
                            <INPUT onclick="location.href='/contractmanager/Apply_kehuisho.html' " type="button" value="返回">
                            <button onclick="Chong()" id="chx">重新审批</button>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="id">
</body>
<script id="button" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="open">打开</a>
    <a class="layui-btn layui-btn-xs" lay-event="Del">删除</a>
</script>
<script>
    layui.use('table', function(){
        $("#div2").hide();
        var table = layui.table;
        table.render({
            elem: '#test'  //html中渲染table的id
            , url: '/contractmanager/jieshilist3'   //后台获取数据集合的地址
            , cellMinWidth: 80
            , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                , groups: 1 //只显示 1 个连续页码
                , first: false//不显示首页
                , last: false //不显示尾页

            }, cols: [
                [
                    //表单显示的title以及返回的需要显示的数据，field值与获取集合中的类的字段名一致。
                    {field: 'id', title: '序号', align: 'center',width:80},
                    {field: 'contAppNum', title: '合同申请编号', align: 'center',width: 150},
                    {field: 'status', title: '状态',toolbar:'#link', align: 'center'},
                    {field: 'leadDate', title: '揭示时间', align: 'center'},
                    {field: 'allSumPrice', title: '报价总金额（元）', align: 'center'},
                    {field: 'statQuote', title: '报价份数', align: 'center'},
                    { title: '操作', toolbar: "#button",align:'center', width:200}
                ]
            ]
        });
        table.on('tool(test)',function (obj) {
            let data = obj.data;
            let cid = data["id"];
            if(obj.event === "open"){
                $("#div1").hide();
                $("#div2").show();
                $.ajax({
                    url:'/contractmanager/findContAppById',
                    data:{"id":cid},
                    type:'post',
                    success:function (result) {
                        $("#enquireName3").html(result.contAppNum);
                        $("#statQuote").html(result.statQuote);
                        $("#topQuote").html(result.topQuote);
                        $("#lowQuote").html(result.lowQuote);
                        $("#sumPrice").html(result.allSumPrice);
                        $("#leadAgree").html(result.leadAgree);
                        $("#leadOpinion").html(result.leadOpinion);
                        $("#id").val(result.id);
                        if(result.status==='废弃'){
                            $("#chx").hide()
                        }
                        $.ajax({
                            url:'/contractmanager/findContAppId',
                            data:{"id":result.id},
                            type:'post',
                            success:function (result1) {
                                $("#orderNum").html(result1.length);
                                let dinghuoNum=0.00;
                                for (let i=0;i<result1.length;i++) {
                                    dinghuoNum+=Number(result1[i].amount);
                                    $("#tableContract").append(
                                        "<TR class=T1>\n" +
                                        "                                                <TD noWrap align=middle colSpan=9>\n" +
                                        "                                                    物资\n" +
                                        "                                                    <B style='color: red'>"+(Number(i)+1)+" &nbsp;\n" +
                                        "                                                    </B><A href=\"javascript:alert('对应需求计划书详细')\" style='color: blue'>"+result1[i].materialName+"</A>\n" +
                                        "                                                    "+result1[i].amount+"个\n" +
                                        "                                                    <B>计划价（元/含税）</B>\n" +
                                        "                                                    \n" +
                                        "                                                    <A\n" +
                                        "                                                        href=\"javascript:alert('对应报价书详细')\"> 报价明细信息</A>&nbsp;&nbsp;\n" +
                                        "                                                </TD>\n" +
                                        "                                            </TR>\n" +
                                        "                                            <TR class=t1>\n" +
                                        "                                                <TD noWrap align=middle width=\"20%\">供应商编号</TD>\n" +
                                        "                                                <TD noWrap align=middle>数量</TD>\n" +
                                        "                                                <TD noWrap align=middle>单价<BR>（元/含税）</TD>\n" +
                                        "                                                <TD noWrap align=middle>运杂费<BR>（元）</TD>\n" +
                                        "                                                <TD noWrap align=middle>其它费用<BR>（元）</TD>\n" +
                                        "                                                <TD noWrap align=middle>总计<BR>（元）</TD>\n" +
                                        "                                                <TD noWrap align=middle>开始<BR>交货期</TD>\n" +
                                        "                                                <TD noWrap align=middle>结束<BR>交货期</TD>\n" +
                                        "                                            </TR>\n"+"                                            <TR class=t2>\n" +
                                        "                                                <TD style='text-align: center' width=\"20%\">"+result1[i].supplierId+"<BR></TD>\n" +
                                        "                                                <TD align=right>"+result1[i].amount+"<BR></TD>\n" +
                                        "                                                <TD align=right>"+result1[i].unitPrice+"<BR></TD>\n" +
                                        "                                                <TD style='text-align: center'  align=right>"+result1[i].mixPrice+"<BR></TD>\n" +
                                        "                                                <TD style='text-align: center'  align=right>"+result1[i].otherPrice+"<BR></TD>\n" +
                                        "                                                <TD style='text-align: center'  align=right>"+result1[i].totalPrice+"<BR></TD>\n" +
                                        "                                                <TD style='text-align: center' >"+result1[i].startDate+"<BR></TD>\n" +
                                        "                                                <TD style='text-align: center' >"+result1[i].endDate+"<BR></TD>\n" +
                                        "                                            </TR>")
                                }

                                $("#dingHuoNum").html(dinghuoNum);
                            }

                        })
                    }
                })
            }else if(obj.event==="Del"){
                layer.confirm('确定执行该操作吗?', function (index) {
                    $.ajax({
                        url: '/contractmanager/Del',
                        data: {"id": cid},
                        type: 'post',
                        success: function (result1) {
                            layer.close(index);
                            layer.alert("删除成功!")
                            setTimeout(() => {
                                location.reload()
                            }, 1500)
                        }

                    })
                })
            }
        })
    });
    function Chong(){
        $.ajax({
            url:'/contractmanager/updateStatus3',
            data:{"id":$.trim($("#id").val())},
            type:'post',
            success:function (result1) {
                layer.alert("重新审批成功!")
                setTimeout(() => {
                    location.reload()
                }, 1500)
            }

        })
    }
</script>
<script id="link" type="text/html">
    <a lay-event="check" class="layui-table-link" target="_self">{{ d.status }}</a>
</script>
</html>